#pragma once

#include <vector>
#include "cocos2d.h"
#include "SilzAstar.h"

typedef struct _tag_cell_data {
    int col;
    int row;
    bool alpha;
    bool obstacle;
}CellData;

class GameMap : public cocos2d::Node
{
public:
    GameMap()
        :_mapWidth(0)
        ,_mapHeight(0)
        ,_cellWidth(0)
        ,_cellHeight(0)
        ,_tiledMap(nullptr)
    {
    }
    virtual ~GameMap() {}
    static GameMap* create(const char *file);
    virtual bool init(const char *file);
    virtual void setOffset(float x, float y);


    const CellData& getCellData(int col, int row) const;
    const std::vector<CellData>& getCellDatas() const { return _cellDatas; }
    int getMapWidth() const { return _mapWidth; }
    int getMapHeight() const { return _mapHeight; }
    float getCellWidth() const { return _cellWidth; }
    float getCellHeight() const { return _cellHeight; }
	void getPath(std::vector<cocos2d::Point> &result, int srcX, int srcY, int descX, int descY);

protected:
    int _mapWidth;
    int _mapHeight;
    int _cellWidth;
    int _cellHeight;
    std::vector<CellData> _cellDatas;
    cocos2d::TMXTiledMap *_tiledMap;
    SilzAstar _astar;
};